package com.nce.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.nce.entity.account.User;
import com.nce.util.ActionLevel;

/**
 *关键字
 * 
 * @author GT
 */
@Entity
//表名与类名不相同时重新定义表名.
@Table(name = "keyword")
//默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Keyword implements Serializable  {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -430038188136037356L;
	private Long id;
	private String words;
	private String actionLevel;
	private Date tmModified = new Date();
	private User user;
	
	
	@Id
	@Column(name="kid")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getWords() {
		return words;
	}

	public void setWords(String words) {
		this.words = words;
	}

	

	@Column(name="action")
	public String getActionLevel() {
		return actionLevel;
	}

	public void setActionLevel(String actionLevel) {
		this.actionLevel = actionLevel;
	}

	public Date getTmModified() {
		return tmModified;
	}

	public void setTmModified(Date tmModified) {
		this.tmModified = tmModified;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinColumn(name = "uid")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String toString() {
		return "Keyword [id=" + id + ", words=" + words + ", action=" + actionLevel
				+ ", tmModified=" + tmModified + ", user=" + user + "]";
	}	

}